/************************************************************
 * Project Name		[Thinking_In_Java]
 * File Name     	[pkg_algorithm.Primes.java]
 * Creation Date 	[13-Jun-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_algorithm;

/**
 * 素数问题
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class Primes {

	/**
	 * 求指定范围内的素数
	 * 
	 * @param start
	 *            起始范围
	 * @param end
	 *            终止范围
	 */
	public static void getPrimes1(int start, int end) {
		int counter = 0;
		outer: for (int i = start; i < end; i++) {
			for (int j = 2; j < i; j++) {
				if (i % j == 0) {
					continue outer;
				}
			}
			System.out.print(i + "\t");
			counter++;
			if (counter == 7) {
				System.out.println();
				counter = 0;
			}
		}
	}

	/**
	 * 求指定范围内的素数
	 * 
	 * @param start
	 *            起始范围
	 * @param end
	 *            终止范围
	 */
	public static void getPrimes2(int start, int end) {
		int counter = 0;
		for (int i = start; i < end; i++) {
			boolean flag = true;
			for (int j = 2; j < i; j++) {
				if (i % j == 0) {
					flag = false;
					break;
				}
			}
			if (flag) {
				System.out.print(i + "\t");
				counter++;
				if (counter == 7) {
					System.out.println();
					counter = 0;
				}
			}
		}
	}
}
